//*********************************************************
//
//    Copyright (c) Microsoft. All rights reserved.
//    This code is licensed under the Apache License, Version 2.0.
//    THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
//    ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
//    IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
//    PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Research.ScientificWorkflow.ManagementStudioControls.Interfaces;
using Microsoft.Practices.Unity;
using System.Windows;
using System.Windows.Input;
using Microsoft.Research.ScientificWorkflow.UIDesigner.WpfComposite;

namespace Microsoft.Research.ScientificWorkflow.ManagementStudioControls.WorkflowManagerModule
{
    public class AvailableWorkflowsPresenter : IWorkflowManagerFilter
    {
        /// <summary>
        /// 
        /// </summary>
        private IUnityContainer container;

        /// <summary>
        /// 
        /// </summary>
        private AvailableWorkflowsListPresenter listPresenter;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="container"></param>
        /// <param name="view"></param>
        public AvailableWorkflowsPresenter(IUnityContainer container, AvailableWorkflowsView view, AvailableWorkflowsListPresenter listPresenter)
        {
            this.container = container;
            this.View = view;
            this.listPresenter = listPresenter;
            view.Presenter = this;
            this.FilterName = ManagementStudioControlsConstants.AVAILABLEWORKFLOWFILTERNAME;
            this.FilterSelected = new DelegateCommand<string>(ExecuteFilterSelected);
        }

        /// <summary>
        /// 
        /// </summary>
        public UIElement View { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public ICommand FilterSelected { get; set; }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="queryCondition"></param>
        private void ExecuteFilterSelected(string queryCondition)
        {
            this.listPresenter.DisplayItems(queryCondition);
        }

        #region IWorkflowManagerFilter Members

        /// <summary>
        /// 
        /// </summary>
        public string FilterName { get; set; }
        
        #endregion
    }
}
